/**
 * Cette classe a ete generee par Arkin Generator
 * @author Nahed Chahine Laventure Aurelien
 */

//IMPORT
import java.util.HashMap;
import com.cyberbotics.webots.controller.*;

//CLASS
public class AAAA extends DifferentialWheels {

	// ATTRIBUTES
	private final int TIME_STEP = 32;
	private HashMap<String, String> courants = new HashMap<String, String>();
	private HashMap<String, Double> values = new HashMap<String, Double>();
	private LED mp;
	private Pen zz;
	private LightSensor light;
	private DistanceSensor dist;

	// CONSTRUCTOR
	public AAAA() {
		super();
		mp = this.getLED("mp");
		zz = this.getPen("zz");
		light = this.getLightSensor("light");
		light.enable(TIME_STEP);
		dist = this.getDistanceSensor("dist");
		dist.enable(TIME_STEP);
		courants.put("courir", "entry");
		courants.put("fuir", "entry2");
	}

	// METHODS
	public static void main(String[] args) {
		AAAA controller = new AAAA();
		controller.run();
	}

	public void doArbiter() {
		if (courir())
			return;
		if (fuir())
			return;
	}

	public boolean courir() {
		boolean inibit = false;
		double value = 0.0;
		String courant = courants.get("courir");
		String self = "courir";
		if (courant.equals("entry")) {
			if ((0.0 == 0.0)) {
				courant = "state2";
				inibit = false;
				value = 200.0;
				mp.set(0);
			} else {
				mp.set(1);
				this.setSpeed(3.0, 3.0);
			}
		} else if (courant.equals("state2")) {
			if ((false || true)) {
				courant = "entry";
				inibit = false;
				value = 20.0;
				mp.set(1);
				this.setSpeed(3.0, 3.0);
			} else if (false) {
				courant = "entry";
				inibit = false;
				value = 20.0;
				mp.set(1);
				this.setSpeed(3.0, 3.0);
			} else {
				mp.set(0);
			}
		}
		courants.put("courir", courant);
		values.put("courir", value);
		return inibit;

	}

	public boolean fuir() {
		boolean inibit = false;
		double value = 0.0;
		String courant = courants.get("fuir");
		String self = "fuir";
		if (courant.equals("entry2")) {
			if (false) {
				courant = "state2 2";
				inibit = false;
				value = 100.0;
			} else {
			}
		} else if (courant.equals("state2 2")) {
			if (true) {
				courant = "entry2";
				inibit = false;
				value = 10.0;
			} else {
			}
		}
		courants.put("fuir", courant);
		values.put("fuir", value);
		return inibit;

	}

	// RUN
	public void run() {

		// Main control loop
		while (step(TIME_STEP) != -1) {
			values.put("light", light.getValue());
			values.put("dist", dist.getValue());
			doArbiter();
		}
	}
}
